package com.ynny.practice11.dao;

import com.ynny.practice11.bean.Xuanke;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class XuankeDaoIpml implements IXuankeDao {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public Xuanke getXuanke(String number) {
        String sql = "select * from xuanke where number = ?";
        Xuanke xuanke = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<Xuanke>(Xuanke.class), number);
        return xuanke;
    }

    @Override
    public int updateXuanke(String number, Integer moive) {
        String sql = "update xuanke set moive =moive + ? where number = ?";
        int update = jdbcTemplate.update(sql, moive, number);

        return update;
    }
}